<?php

namespace App\Http\Controllers\Api;

use App\Http\Requests\UpdatePrivacRequest;
use App\PrivacSet;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Auth;

//隐私设置
class PrivacSetUpController extends Controller
{
    //获取我的隐私设置
    public function myPrivac()
    {
        return PrivacSet::where('uid', Auth::id())->first();
    }

    //修改我的隐私设置
    public function updatePrivac(UpdatePrivacRequest $request, PrivacSet $privacSet)
    {
        if ($privacSet::where('uid', Auth::id())->update($request->only(['is_assess_psychology', 'is_assess_yijing', 'is_sex']))) {
            return response(['message' => '修改成功', 'data' =>$privacSet::where('uid', Auth::id())->first()]);
        }
        return response(['message' => '修改失败', 'data' => $privacSet::where('uid', Auth::id())->first()], 400);
    }
}
